﻿using System;
using System.Diagnostics;
using System.Runtime.Serialization;

namespace CSC.Google
{
    /// <summary>
    /// Rule result
    /// </summary>
    [Serializable]
    public class RuleResult
    {
        #region Private Variables
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private string localizedRuleName = string.Empty;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private int ruleScore = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private double ruleImpact = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private UrlBlock[] urlBlocks = new UrlBlock[0];
        #endregion

        /// <summary>
        /// Localized name of the rule, intended for presentation to a user.
        /// </summary>
        public string LocalizedRuleName { get { return localizedRuleName; } }

        /// <summary>
        /// The score (0-100) for this rule. The rule score indicates how well a page implements the recommendations for the given rule. For instance, if none of the compressible resources on a page are compressed, the rule score would be 0, while if all of the compressible resources on a page are compressed, the rule score would be 100.
        /// </summary>
        public int RuleScore { get { return ruleScore; } }

        /// <summary>
        /// The impact (unbounded floating point value) that implementing the suggestions for this rule would have on making the page faster. Impact is comparable between rules to determine which rule's suggestions would have a higher or lower impact on making a page faster. For instance, if enabling compression would save 1MB, while optimizing images would save 500kB, the enable compression rule would have 2x the impact of the image optimization rule, all other things being equal.
        /// </summary>
        public double RuleImpact { get { return ruleImpact; } }

        /// <summary>
        /// List of blocks of URLs. Each block may contain a heading and a list of URLs. Each URL may optionally include additional details.
        /// </summary>
        [DebuggerDisplay("Count = {UrlBlocks.Length}")]
        public UrlBlock[] UrlBlocks { get { return urlBlocks; } }
    }
}
